
<?php
  //=========================<script réaliser par :EZZAMANE SOUKAINA>===================

      include("verifierSession.php");
      require_once("beans/materielBean.php");
      require_once("beans/nomadeBean.php");
      require_once("beans/tacheBean.php");
      require_once("dao/nomadeDao.php");
       require_once("dao/tacheDao.php");
      require_once("dao/cableethernetDao.php");
      include('connectBD.php');
      extract($_POST);
      
       
       
      $login=$_SESSION['login'];
      $nomade  =new nomadeBean();
      $nomadeDao= new nomadeDao();
      $tacheDao= new tacheDao();
      $nomade=$nomadeDao->loadNomadeByLogin($login);
      $cableethernetDao =new cableethernetDao();  //instanciation du bean carteDao class des CRUD
     
      $tab = (isset($_POST["cableethernet"]))?$_POST["cableethernet"]:null;
    
       if($tab and isset($_POST["quantite"])) 
      {    
          $materiel=new materielBean();
          $cableethernet   =new materielBean();
          $materiel->setConstructeur($tab);
          $cableethernet=$cableethernetDao->loadCableethernet($materiel);
          $cableethernetDao->insertMateriel($cableethernet,$quantite,$nomade->getIdNomade(),$tache) ;
          $tpl->display("succees.html");
     }
    else
    {
      $tache=$tacheDao->loadAllTacheByDesignation();
     $materiels=$cableethernetDao->loadAllCableethernetByType();
     $title="Câble Ethernet";
     $tpl->assign('cableethernet',$materiels);
     $tpl->assign('tache',$tache);
     $tpl->assign('title',$title);
     $tpl->display("cableethernet.html");
    }
   
?>